﻿using System;
using Types.Enumerations;

namespace Types.CustomTypes
{
    [Serializable()]
    public class CCustomException
    {
        private EnumExceptionType mExType;
        private string mErrorMessage;
        private string mErrorCode;
        private string mInnerExceptionString;
        private string mErrorMethodName;
        private string mLogKey;
        private string mErrorDetail;

        public EnumExceptionType ExType
        {
            get { return mExType; }
            set { mExType = value; }
        }

        public string ErrorMessage
        {
            get { return mErrorMessage; }
            set { mErrorMessage = value; }
        }

        public string ErrorCode
        {
            get { return mErrorCode; }
            set { mErrorCode = value; }
        }

        public string InnerExceptionString
        {
            get { return mInnerExceptionString; }
            set { mInnerExceptionString = value; }
        }

        public string ErrorMethodName
        {
            get { return mErrorMethodName; }
            set { mErrorMethodName = value; }
        }

        public string LogKey
        {
            get { return mLogKey; }
            set { mLogKey = value; }
        }

        public string ErrorDetail
        {
            get { return mErrorDetail; }
            set { mErrorDetail = value; }
        }

        public CCustomException()
        {
            CleanParameters();
            this.mExType = EnumExceptionType.SystemException;
            this.mErrorMessage = "Hata Oluştu";
            this.mErrorCode = "SistemHatası";
        }
        public CCustomException(EnumExceptionType pExceptionType, string pErrorMessage, string pErrorCode)
        {
            CleanParameters();
            this.mExType = pExceptionType;
            this.mErrorMessage = pErrorMessage;
            this.mErrorCode = pErrorCode;
        }
        public CCustomException(EnumExceptionType pExceptionType,string pErrorDetail, string pErrorMessage, string pErrorCode, string pErrorMethodName, string pLogKey)
        {
            CleanParameters();
            this.mExType = pExceptionType;
            this.mErrorDetail= pErrorDetail;
            this.mErrorMessage = pErrorMessage;
            this.mErrorCode = pErrorCode;
            this.mErrorMethodName = pErrorMethodName;
            this.mLogKey = pLogKey;
        }

        private void CleanParameters()
        {
            mErrorMessage = string.Empty;
            mErrorCode = string.Empty;
            mInnerExceptionString = string.Empty;
            mErrorMethodName = string.Empty;
            mLogKey = string.Empty;
            mErrorDetail = string.Empty;
        }
    }
}
